package com.csjy.migration.hnnd.workflow;

import com.csjy.migration.hnnd.DbUtil;
import com.csjy.migration.hnnd.ProgramArgument;
import com.csjy.migration.hnnd.annotation.Task;
import com.csjy.migration.hnnd.business.NdBpmCounterGuarantee;
import com.csjy.migration.hnnd.business.NdBpmProjectArchive;
import com.csjy.migration.hnnd.business.SourceBusinessData;
import com.fasterxml.jackson.core.JsonProcessingException;

import javax.script.ScriptException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/*补交法律资料(item-sencor-prefix-datum-hny)
phs*/

public class ItemSencorPrefixDatumHny extends WorkflowMigration{
    private NdBpmProjectArchive ndBpmProjectArchive = null;
    private NdBpmCounterGuarantee ndBpmCounterGuarantee = null;

    public ItemSencorPrefixDatumHny(DbUtil sourceDbUtil, DbUtil targetDbUtil, SourceBusinessData sourceData, ProgramArgument programArgument, String projectId, String procInstId, Map procInstRow) throws Exception {
        super(sourceDbUtil, targetDbUtil, sourceData, programArgument, projectId, procInstId, procInstRow);
        this.customInitData();
    }

    @Override
    public void customInitData() throws SQLException {
        this.curBizType = "bjflzl";
        ndBpmProjectArchive  = new NdBpmProjectArchive(this.sourceDbUtil,this.targetDbUtil,sourceData, programArgument,this.projectId,this.procInstId);
        ndBpmCounterGuarantee = new NdBpmCounterGuarantee(this.sourceDbUtil,this.targetDbUtil,sourceData, programArgument,this.projectId,this.procInstId , true);
    }


    @Override
    public void customInsertOrUpdateData() throws Exception {
        ndBpmProjectArchive.start();
        ndBpmCounterGuarantee.start();
    }

    @Task("补交法律资料@项目经理补交法律资料")
    public void xmjlbjflzl() throws Exception {

        this.curModelMap.put("all",new String[]{"task1535593390830xyb","下一步"});
        this.curAffixType = "bcgdzl";
        this.curAffixTypeCommon = this.curAffixType;
        this.setCommonData(true,null);

        Map<String,Object> taskParam =  this.initTaskParamMap();
        taskParam.put("isPigeonhole", "0");
        taskParam.put("archiveCategory", "A类");
        ndBpmProjectArchive.getTaskParamMap().put(this.curJbpmTaskInstanceId, taskParam);

    }
    @Task("补交法律资料@风控部审核处理")
    public void fkbshcl() throws Exception {
        this.curModelMap.put("通过",new String[]{"task1535593387975tg","同意"});
        this.setCommonData(true,null);
        ndBpmCounterGuarantee.getTaskParamMap().put(this.curJbpmTaskInstanceId,  this.initTaskParamMap());
    }
    @Task("补交法律资料@档案管理员接收处理")
    public void daglyjscl() throws Exception {
        this.curModelMap.put("确认接收",new String[]{"endqrjs","确认接收"});
        this.curModelMap.put("未接收资料",new String[]{"endwjszl","未接收资料"});
        this.curAffixType = "bcgdzl";
        this.curAffixTypeCommon = this.curAffixType;
        this.setCommonData(true,null);

        Map<String,Object> taskParam =   this.initTaskParamMap();

        taskParam.put("isPigeonhole", this.curJbpmTaskInstanceRow.get("ISOPEN_").toString().equals("1") ? "0" : "1");
        taskParam.put("archiveCategory", "A类");
        ndBpmProjectArchive.getTaskParamMap().put(this.curJbpmTaskInstanceId, taskParam);
    }
}
